/**
* \file TCPSocket.cpp
* \brief TCPSocket definition class
* \author Edouard ROGE
* \date 12 Novembre 2013
*/

#include "TCPSocket.h"

TCPSocket::TCPSocket()
{
	m_iDescriptor = socket(AF_INET, SOCK_STREAM, 0);
}

TCPSocket::~TCPSocket()
{
	Close();
}

void TCPSocket::Send(void * _pBuffer, uint32 _iSize)
{
	send(m_iDescriptor, (char*)_pBuffer, _iSize, 0);
}

void TCPSocket::Receive(void * _pBuffer, uint32 _iSize)
{
	recv(m_iDescriptor, (char*)_pBuffer, _iSize, 0);
}

void TCPSocket::Connect(const std::string & _strAddress, uint32 _iPort)
{
	/*struct sockaddr_in sin = { 0 };
	inet_pton(AF_INET, _strAddress.GetData(), &(sin.sin_addr));
	sin.sin_port = htons(_iPort);
	sin.sin_family = AF_INET;
	connect(m_iDescriptor, (struct sockaddr*)&sin, sizeof(struct sockaddr_in));*/
}

void TCPSocket::Close()
{
	close(m_iDescriptor);
}